﻿@using UI.Nafania.Helpers
@model WebService.Nafania.BussinesLayer.Model.Generator.LineResult

@section JavaScript
{
	<script type="text/javascript">
		$(document).ready(function () {
			updateCodeView();			

			$('li', '#rotate').click(function () {
				var lines = @Html.Raw(Model.ToLineArray());
				var box = @Html.Raw(Model.ToBlockArray());
				
				var lineNum = $(this).index() + 1;
				var blockGuid = lines[lineNum];
				var boxRange = box[blockGuid];
			
				updateCodeView(boxRange);

				$.ajax({
						url: '@Html.Raw(Url.Action("BlockData", "Home", new {alias = Model.Alias, name = Model.Name, version = Model.Version, blockId = Guid.Empty}))'.replace('@Guid.Empty', blockGuid),
						success: function (data) {
							$('#block-value').html(data);
						},
						beforeSend: function () {
							$('#pinner').show();
							$('#block-value').hide();
							$('#block-value').html('');
						},
						complete: function () {
							$('#pinner').hide();
							$('#block-value').show();
						}
					});
			});
			
		});
		
		function updateCodeView(box) {
			var snippetSettings = {
				style: "ide-msvcpp",
				clipboard: "/Scripts/jquery/snippet/ZeroClipboard.swf"
			};
			
			if (box != null) {
				snippetSettings.box = box;
				snippetSettings.boxColor = "gray";
				snippetSettings.boxFill = "#e0e0e0";
			}

			$("#rotate").snippet("csharp", snippetSettings);
		}
	</script>

  <script src="@Url.Content("~/Scripts/custom/block-actions.js")" type="text/javascript"></script>
}

@{
    ViewBag.Title = "Object";
}


<pre id="rotate">@Model.Text</pre>

<div id="pinner" style="display: none;"></div>
<div id="block-value"></div>
